<template>
	<view class='page'>
		<navigator url="../../user-center/news-detail/news-detail?id=8" class='message' hover-class="none">
			<image src='https://gy-files.oss-cn-shenzhen.aliyuncs.com/picture/merchant/establish/store-guide.jpg'></image>
		</navigator>
		<form @submit="handleWorkerSubmit" report-submit='true'>
			<view class='weui-title'>
				<image class='weui-title-img' src='https://gy-files.oss-cn-shenzhen.aliyuncs.com/picture/merchant/establish/headline.png'></image>
				<text class='weui-title-title'>店铺基本信息</text>
				<image class='weui-title-img' src='https://gy-files.oss-cn-shenzhen.aliyuncs.com/picture/merchant/establish/headline.png'></image>
			</view>
			<view class='weui-cells' style='margin-top:0;'>
				<view class="weui-cell">
					<view class="weui-cell__bd">
						<view class="weui-cell__bd">
							<view class="weui-uploader">
								<view class="weui-uploader__hd">
									<view class="weui-uploader__title upload-title dis-hd">
										<image class='weui-cell__hd__img' src='https://gy-files.oss-cn-shenzhen.aliyuncs.com/picture/merchant/establish/photo.png'></image>店铺头像
									</view>
								</view>
								<view class="weui-uploader__bd padding56">
									<view class="weui-uploader__files" id="uploaderFiles">
										<block v-for="(item,index) in photoFiles" wx:key="*this">
											<view class="weui-uploader__file" @tap="allPreview" :id="item" data-name='photo' style="position: relative">
												<image class="weui-uploader__img" :src="item" mode="aspectFill" />
												<view class="weui-badge" style="position: absolute;top: 0em;right: 0em;" :id="item" :data-index="index"
												 @tap.stop='allDeletePhoto' data-name='photo'>-</view>
											</view>
										</block>
									</view>
									<view class="weui-uploader__input-box radius15" v-if="photoFiles.length < 1">
										<!-- <view class="weui-uploader__input" @tap='chooseAvatarIMG' data-name='photo' data-sum='1'></view> -->
										<view class="weui-uploader__input" @tap='allChooseImage' data-name='photo' data-sum='1'></view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
				<view class="weui-cell">
					<view class="weui-cell__hd">
						<image class='weui-cell__hd__img' src='https://gy-files.oss-cn-shenzhen.aliyuncs.com/picture/merchant/establish/name.png'></image>店铺名称
					</view>
					<view class="weui-cell__bd">
						<input type='text' placeholder='店铺名称' @blur="bindTitle" :value="myData.name" name="name" maxlength='10' style='width:100%;text-align: right;'></input>
					</view>
				</view>
				<view class='weui-cells weui-cells__title_a'>
					<view class='weui-cell'>
						<view class="weui-cell__hd">
							<image class='weui-cell__hd__img' src='https://gy-files.oss-cn-shenzhen.aliyuncs.com/picture/merchant/category.png'></image>主营品种
						</view>
						<view class="weui-cell__bd"></view>
						<view class="weui-cell__ft dp-flex">
							<view class='border-radius' @tap='mainCategoryChange'>{{categoryMainName ? categoryMainName : "品类1"}}</view>
							<view class='border-radius' @tap='subCategoryChange'>{{categorySubName ? categorySubName : "品类2"}}</view>
						</view>
					</view>
					<view class='weui-cell'>
						<view class='fontsize-16' style='color:#999;'>品类1必填，品类2选填。</view>
					</view>
				</view>

			</view>

			<view class='weui-cells'>
				<view class="weui-cell">
					<view class="weui-cell__hd">
						<image class='weui-cell__hd__img' src='https://gy-files.oss-cn-shenzhen.aliyuncs.com/picture/merchant/establish/site.png'></image>店铺地址
					</view>
					<view class="weui-cell__bd"></view>
					<input placeholder='请选择具体位置' :value="detailLoc" class='weui-cell__ft weui-cell__ft_in-access' style='width:65%;'
					 name='address' @tap='handleDetailLoc' disabled='true'></input>
				</view>
			</view>

			<view class='weui-cells'>
				<view class="weui-cell">
					<view class="weui-cell__bd">
						<view class="weui-cell__bd">
							<view class="weui-uploader">
								<view class="weui-uploader__hd">
									<view class="weui-uploader__title upload-title dis-hd">
										<image class='weui-cell__hd__img' src='https://gy-files.oss-cn-shenzhen.aliyuncs.com/picture/merchant/establish/facility.png'></image>店内设施
										<text class='color-a9'>(此图为默认图,如需更改请点击更换图片)</text>
									</view>
								</view>
								<view class="weui-uploader__bd padding56">
									<view class="weui-uploader__files" id="uploaderFiles">
										<block v-for="(item,index) in files">
											<view class="weui-uploader__file" @tap="allPreview" :id="item" data-name='pictures' style="position: relative;width:85%;">
												<image class="weui-uploader__img" style='width:100%;height:60upx;' :src="item" mode="aspectFill" />
												<view class="weui-badge changPicture" :id="item" :data-index="index" @tap.stop='allDeletePhoto' data-name='pictures'>-</view>
											</view>
										</block>
									</view>
									<view class="weui-uploader__input-box radius15" v-if="files.length < 1">
										<view class="weui-uploader__input" @tap="allChooseImage" data-name='pictures' data-sum='1'></view>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>

			<view class='weui-cells'>
				<view class="weui-cell">
					<view class="weui-cell__bd">
						<view class='weui-uploader'>
							<view class='weui-uploader__hd'>
								<view class='weui-uploader__title upload-title dis-hd'>
									<image class='weui-cell__hd__img' src='https://gy-files.oss-cn-shenzhen.aliyuncs.com/picture/merchant/establish/datum.png'></image>店铺简介
								</view>
							</view>
							<view class='weui-uploader__bd padding56'>
								<textarea v-if="!successfulOrderPop" class="weui-textarea" @blur="bindTextAreaBlur" @focus='showButton' @input='textareaInput'
								 :value="myData.introduce? myData.introduce : 'ceshi'" placeholder="请输入店铺的主营产品和竞争优势" name="introduce" maxlength='200' />
								</view>
	          </view>
	        </view>
	      </view>
	    </view>
	
	    <view class='weui-title'>
	      <image class='weui-title-img' src='https://gy-files.oss-cn-shenzhen.aliyuncs.com/picture/merchant/establish/headline.png'></image>
	      <text class='weui-title-title'>店铺装修信息</text>
	      <image class='weui-title-img' src='https://gy-files.oss-cn-shenzhen.aliyuncs.com/picture/merchant/establish/headline.png'></image>
	    </view>
	
	   <view class='weui-cells' style='margin-top:0;'>
	      <view class="weui-cell">
	        <view class="weui-cell__bd">
	          <view class="weui-cell__bd">
	            <view class="weui-uploader">
	              <view class="weui-uploader__hd">
	                <view class="weui-uploader__title upload-title dis-hd">
	                  <image class='weui-cell__hd__img' src='https://gy-files.oss-cn-shenzhen.aliyuncs.com/picture/merchant/establish/carousel.png'></image>顶部轮播图</view> 
	                <view class="weui-uploader__info">{{slideFiles.length}}/4</view>
	              </view>
	              <view class="weui-uploader__bd padding56">
	                <view class="weui-uploader__files" id="uploaderFiles">
	                  <block v-for="(item,index) in slideFiles" >
	                    <view class="weui-uploader__file" @tap="allPreview" :id="item" data-name='slideshow' style="position: relative">
	                      <image class="weui-uploader__img" :src="item" mode="aspectFill" />
	                      <view class="weui-badge" style="position: absolute;top: 0em;right: 0em;" :id="item" :data-index="index" @tap.stop='allDeletePhoto' data-name='slideshow'>-</view>
	                    </view>
	                  </block>
	                </view>
	                <view class="weui-uploader__input-box radius15" v-if="slideFiles.length < 4">
	                  <view class="weui-uploader__input" data-name='slideshow' @tap="allChooseImage" data-sum='4'></view>
	                </view>
	              </view>
	            </view>
	          </view>
	        </view>
	      </view>
	      <view class="weui-cell">
	        <view class="weui-cell__bd">
	          <view class="weui-cell__bd">
	            <view class="weui-uploader">
	              <view class="weui-uploader__hd">
	                <view class="weui-uploader__title upload-title dis-hd">
	                  <image class='weui-cell__hd__img' src='https://gy-files.oss-cn-shenzhen.aliyuncs.com/picture/merchant/establish/environment.png'></image>店铺介绍图</view>
	                <view class="weui-uploader__info">{{intrFiles.length}}/9</view>
	              </view>
	              <view class="weui-uploader__bd padding56">
	                <view class="weui-uploader__files" id="uploaderFiles">
	                  <block v-for="(item,index) in intrFiles" >
	                    <view class="weui-uploader__file" @tap="allPreview" :id="item" data-name='introduce' style="position: relative;width:30%">
	                      <image class="weui-uploader__img" :src="item" mode="aspectFill" style='width:100%;height:108px;border-radius:15upx;'/>
	                      <view class="weui-badge" style="position: absolute;top: 0em;right: 0em;" :id="item" :data-index="index" @tap.stop='allDeletePhoto' data-name='introduce'>-</view>
	                    </view>
	                  </block>
	                </view>
	                <view class="weui-uploader__input-box radius15" v-if="intrFiles.length < 9">
	                  <view class="weui-uploader__input" data-name='introduce' @tap="allChooseImage" data-sum='9'></view>
	                </view>
	              </view>
	            </view>
	          </view>
	        </view>
	      </view>
	
	      <view class="weui-cell">
	        <view class="weui-cell__bd">
	          <view class="weui-cell__bd">
	            <view class="weui-uploader">
	              <view class="weui-uploader__hd">
	                <view class="weui-uploader__title upload-title dis-hd">
	                  <image class='weui-cell__hd__img' src='https://gy-files.oss-cn-shenzhen.aliyuncs.com/picture/merchant/establish/ewm.png'></image>微信二维码
	                  <text class='color-a9'>(上传您店铺用来营销的微信二维码)</text>
	                </view>
	              </view>
	
	
	

	              <view class="weui-uploader__bd padding56">
	                <view class="weui-uploader__files" id="uploaderFiles">
	
	                      <block v-for="(item,index) in ewmFiles" >
	                        <view class="weui-uploader__file" @tap="allPreview" :id="item" data-name='ewm' style="position: relative">
	                          <image class="weui-uploader__img" :src="item" mode="aspectFill" />
	                          <view class="weui-badge" style="position: absolute;top: 0em;right: 0em;" :id="item" :data-index="index" @tap.stop='allDeletePhoto' data-name='ewm'>-</view>
	                        </view>
	                      </block>
	
	
	
	
	                </view>
	               
	                <view v-if="ewmFiles.length < 1">
	                  <view class="weui-uploader__input-box radius15" hover-class='none' >
	                   <!-- <view class="weui-uploader__input" @tap='chooseEwmIMG' data-name='ewm' data-sum='1'></view> -->
					    <view class="weui-uploader__input" @tap='allChooseImage' data-name='ewm' data-sum='1'></view>
	                  </view>
	                </view>
	              </view>
	
	
	
	
	            </view>
	          </view>
	        </view>
	      </view>
	    </view>

	    <view class='btn-area'>
	      <button class='submit-btn' id='1' hover-class formType="submit">保存</button>
	      <button class='submit-btn' id='2' hover-class formType="submit">预览</button>
	      <button class='submit-btn' id='3' hover-class formType="submit">发布</button>
	    </view>
	  </form>
	  
	  
	  <view class='service'>
	    <text>入驻过程中遇到问题？</text>
	    <view class='service-btn' @tap='service'>点击联系平台客服</view>
	  </view>

	</view>
</template>

<script>
	/*引入基类文件*/
	import app from '@/App.vue';
	import event from '@/utils/event.js';
	/*引入接口文件*/
	import {
		GYZJMODEL as gyzjModel
	} from '@/utils/gyzjModel.js';
	export default {
		onLoad() {
				var arr=this.main_getGlobal();
				this.myMerchant(arr.token,arr.type);
			    // this.userInfo = app.globalData.userInfo;
			    // console.log('token初始值'+token);
			    // let token = app.globalData.token;
			    // this.getMerchantInfo(token);
		},
		data() {
			return {
				userInfo:'',
				    files: ['https://gy-files.oss-cn-shenzhen.aliyuncs.com/picture/pictures.png'],
				    slideFiles:[], //轮播
				    intrFiles:[],  //店铺介绍
				    photoFiles:[],  //商品图片
				    ewmFiles:[],  //二维码图片
				    merchant_id:'',
				    isVip:false,
				    myData:{},
					detailLoc:'',
					categoryMainId:'', //主选品类id
					categoryMainName:'',//主选品类名字
					categorySubName:'', //主选品类名字
					categorySubId:'',//主选品类id
				    //裁剪图片位置
				    // cropper_src: '',
			}
		},
		methods: {
			  // 预览图片
			    allPreview: function (e) {
			      console.log('我的ewmFiles的长度'+this.ewmFiles.length);
			      let name = e.currentTarget.dataset.name;
			      if (name == 'photo') {
			        this.previewImage(e.currentTarget.id, this.photoFiles)
			      } else if (name == 'ewm') {
			        this.previewImage(e.currentTarget.id, this.ewmFiles)
			      } else if (name == 'pictures') {
			        this.previewImage(e.currentTarget.id, this.files)
			      } else if (name == 'slideshow') {
			        console.log(this.slideFiles)
			        this.previewImage(e.currentTarget.id, this.slideFiles)
			      } else if (name == 'introduce') {
			        this.previewImage(e.currentTarget.id, this.intrFiles)
			      }
			    },
				 // 预览图片函数
				  previewImage:function (id,data) {
				    uni.previewImage({
				      current: id, 
				      urls: data
				    })
				  },
			//一进来执行我的店铺
			myMerchant:function (token,type) {
			    gyzjModel.prototype.myMerchants(token,type).then(res => {
				  switch(res.code){
					  case 1:
						var myData = res.data.data[0];
						var categoryMainName=this.categoryMainName;
						var categorySubName=this.categorySubName;
						if (!myData.address) {
							console.log('店铺地址1');
						  this.detailLoc = this.userInfo.address;
						}else {
							console.log('店铺地址2');
						  this.detailLoc = myData.address;
						}
						if (myData.ads_pictures) {
						  this.files[0] = myData.ads_pictures;
						}
						if (myData.shop_avatar) {
						  console.log('我的店铺头像所有信息' + myData.shop_avatar);
						  this.photoFiles[0]=myData.shop_avatar;
						  console.log('我的店铺头像photoFiles所有信息' + this.photoFiles);
						}
						if (myData.wechat_qr_code) {
						  console.log('我的店铺二维码所有信息' + myData.wechat_qr_code);
						  this.ewmFiles[0]=myData.wechat_qr_code;
						  console.log('我的店铺二维码ewmFiles所有信息' + this.ewmFiles);
						}
						if (myData.poster) {
						  this.slideFiles = myData.poster;
						}
						if (myData.introduce_map) {
						  console.log('我的店铺介绍图所有信息' + myData.introduce_map);
						  this.intrFiles = myData.introduce_map
						  console.log('我的店铺二维码intrFiles所有信息' + this.intrFiles);
						}
						if (myData.main_category) {
							console.log('进来有数据myData.main_category',myData.main_category);
						  this.categoryMainName = myData.main_category;
						  this.categoryMainId = myData.category_id;
						}else{
							console.log('进来无数据myData.main_category',myData.main_category);
						  	this.categoryMainName= categoryMainName;
						}
						if (myData.sub_category) {
							console.log('进来有数据myData.sub_category',myData.sub_category);
						  this.categorySubName = myData.sub_category;
						}else {
							console.log('进来无数据myData.sub_category',myData.sub_category);
						  this.categorySubName= categorySubName;
						}
						this.myData= myData;
						default:
							uni.hideLoading();
							uni.showToast({
								title: res.message,
								icon: 'none'
							})
							break;
			        }
			     
			    })
			  },
			// 选择品类1
			  mainCategoryChange: function (e) {
			    wx.navigateTo({
			      url: '../../vip-info/category/category?cat=主&type=1',
			    })
			    return;
			  },
		   // 选择品类2
			subCategoryChange: function (e) {
			  uni.navigateTo({
				url: '../../vip-info/category/category?cat=次',
			  })
			  return;
			},
			/*main_getGlobal全局公共函数*/
			main_getGlobal() {
				let globalData = app.globalData;
				console.log('进来globalData', globalData);
				var type, token, arr = new Array();
				if (globalData.mobile) {
					arr['type'] = 2;
					arr['token'] = globalData.mobile;
					console.log('arr为mobile', arr);
				} else if (globalData.token) {
					arr['type'] = 1;
					arr['token'] = uni.getStorageSync('token');
					console.log('arr为token', arr);
				}
				return arr;
			},
			/*删除所有图片的函数*/
			  allDeletePhoto: function (e) {
			    let index = e.currentTarget.dataset.index;
			    let name = e.currentTarget.dataset.name;
			    if (name == 'photo') {
			      this.deletePhoto(this.photoFiles, index, 'photoFiles')
			    } else if (name == 'ewm') {
			      this.deletePhoto(this.ewmFiles, index, 'ewmFiles')
			    } else if (name == 'pictures') {
			      this.deletePhoto(this.files, index, 'files')
			    }else if (name == 'slideshow') {
			      this.deletePhoto(this.slideFiles, index, 'slideFiles')
			    } else if (name == 'introduce') {
			      console.log(this.intrFiles);
			      this.deletePhoto(this.intrFiles, index, 'intrFiles');
			    }
			  },
			/*删除单图的处理函数*/
			deletePhoto:function(data,index,name){
				let photoName;
				/*轮播图和介绍图的删除*/
					if(name=='intrFiles'){
						photoName='introduce_map';
					}else if(name=='slideFiles'){
						photoName='poster';
					}else if(name=='ewmFiles'){
						photoName='wechat_qr_code';
					}else if(name=='photoFiles'){
						photoName='shop_avatar';
					}else if(name=='files'){
						photoName='ads_pictures';
					}
					let picUrl=data[index];
					let merStart=picUrl.indexOf('merchant/'+this.myData.id+'/');
					let merEnd=String('merchant/'+this.myData.id+'/').length;
					let merLen=merStart+merEnd;
					console.log('删除的长度',merLen);
					//判断当前页删除地址是否正确
					let postData={
						'picture':picUrl.slice(merLen),
						'name':photoName
					}
					var arr=this.main_getGlobal();
					gyzjModel.prototype.merchantDeletePhoto(postData,arr.token,arr.type).then(res=>{
						switch(res.code){
							  case 1:
								data.splice(index,1);
								if(name=='intrFiles'){
									console.log('顶部轮播图');
									this.intrFiles=data;
								}else if(name=='slideFiles'){
									console.log('介绍图进来');
									this.slideFiles=data;
								}else if(name=='ewmFiles'){
									this.ewmFiles=data;
								}else if(name=='photoFiles'){
									this.photoFiles=data;
								}else if(name=='files'){
									this.files=data;
								}
								default:
									uni.showToast({
										title: res.message,
										icon: 'none'
									})
									break;
						  }
					})
				
				
			},
			/*保存预览与发布*/
			handleWorkerSubmit:function (e) {
				var arr=this.main_getGlobal();
			    let id = e.detail.target.id;
			    let postData = e.detail.value;
			    let thisData = this;
				console.log('保存的postData',postData);
				//验证店铺名称，简介，地址
			    if (!this.isVerifySuccess(postData)) {
			      return uni.hideLoading();
			    };
			
			    let category_id;
			    thisData.userInfo.type == '4' ? category_id = this.categoryMainId : category_id = 0;
			    if (id == '1') { //保存
				console.log('保存店铺进来');
			      console.log(thisData.ewmFiles)
			      let data = {
			        name: postData['name'],
			        category_id: category_id, //分类
			        ads_pictures: thisData.files, //店内设施
			        poster: thisData.slideFiles, //顶部轮播
			        introduce_map: thisData.intrFiles, //介绍图
			        wecaht_qr_code: thisData.ewmFiles[0],  //微信二维码
			        shop_avatar: thisData.photoFiles[0], //店铺头像
			        address: postData['address'], //地址
			        introduce: postData['introduce'], //介绍
			        main_category: this.categoryMainName, //主营
			        sub_category: this.categorySubName, //次营
			      }
			      uni.showLoading({
			        title: '保存中...',
			      })
			      gyzjModel.prototype.getSaveMerchants(arr.token,arr.type,data).then(res=> {
			        if (res.code == 1) {
						   console.log('保存创建成功的值',res);
			          uni.hideNavigationBarLoading(); //完成停止加载
			          uni.showToast({
			            title:"保存成功",
			            icon: 'success'
			          })
			          this.merchant_id = res.message.merchant_id;
			        }else {
			          uni.showToast({
			            title: res.message,
			            icon: 'none'
			          })
			        }
			      })
			    }else if (id == '2') { //预览
				console.log('预览店铺进来');
			      if (!this.merchant_id) {
			        return uni.showToast({
			          title: "请先保存店铺信息",
			          icon: 'none'
			        })
			      }else {
			        uni.navigateTo({
			          url: '../merchant?merId=' + this.merchant_id + '&type=1',
			        })
			      }
			      
			    }else if (id == '3'){ //发布
				console.log('发布店铺进来');
			      if (!this.merchant_id) {
			        return uni.showToast({
			          title: "请先保存店铺信息",
			          icon: 'none'
			        })
			      }
			      if (this.userInfo.viplever_id != '2' && this.userInfo.viplever_id != '3') {
			        uni.navigateTo({
			          url: '../../user-center/vip-card/vip-card',
			        })
			        console.log(this.isVip)
			      }else {
			        let data = {
			          merchant_id: this.merchant_id
			        }
			        uni.showLoading({
			          title: '发布中...',
			        })
			        gyzjModel.prototype.issueMerchants(data, token,type).then((res) => {
			          console.log(res)
			          if (res.code == 1) {
			            uni.hideNavigationBarLoading(); //完成停止加载
			            this.succeedMerchant();
			          }else {
			            uni.showToast({
						  title: res.message,
						  icon: 'none'
						});
			          }
			        })
			      }
			    }
			  },
			  
			  //店铺创建成功的处理
			  succeedMerchant:function () {
			      uni.showModal({
			        content: '店铺创建成功，是否立即查看我的店铺。',
			        success(res) {
			          if (res.confirm) {
			            uni.navigateTo({
			              url: '../my-merchant/my-merchant',
			            })
			          }
			        }
			      })
			    },
			   // 验证是否成功
			    isVerifySuccess: function (postData) {
			      let flag = this.verifyFormData(postData);
			      if (flag === '1') {
					  console.log('进来flag为1的执行');
			        uni.showModal({
			          content: '请完善店铺名称!',
			          showCancel: false,
			          confirmColor: '#f94c48',
			        })
			        return false
			      } else if (flag === '2') {
					  console.log('进来flag为2的执行');
			        uni.showModal({
			          content: '请选择您店铺的位置!地图可放大缩小，位置可移动!',
			          showCancel: false,
			          confirmColor: '#f94c48',
			          success: res => {
			            if (res.confirm) {
			              this.handleDetailLoc();
			            }
			          }
			        })
			        return false
			      } else if (flag === '3') {
					  console.log('进来flag为3的执行');
			        uni.showModal({
			          content: '请完善您的店铺简介!',
			          showCancel: false,
			          confirmColor: '#f94c48'
			        })
			        return false
			      } 
			      return true
			    },
				 // 验证表单数据
				  verifyFormData: function (formData) {
				    if (!formData['name']) return '1';
				    if (!formData['address']) return '2';
				    if (!formData['introduce']) return '3';
				    return true;
				  },
				   // 工程地点选择
				    handleDetailLoc: function (e) {
				      uni.chooseLocation({
				        success: (res) => {
				          if (res.address) {
				            this.detailLoc=res.address;
							this.longitude=res.longitude;
							this.latitude=res.latitude;
				          }
				          console.log(this.detailLoc)
				        },
				        fail: (res) => {
				          uni.showModal({
				            title: '获取位置授权失败',
				            content: '请手动点击右上角"三个圆点—关于—三个圆点—设置"打开地理位置授权',
				          })
				        }
				      })
				    },
			// 头像选择图片
			  allChooseImage: function (e) {
			    let that = this;
			    let name = e.currentTarget.dataset.name;
			    let sum = Number(e.currentTarget.dataset.sum);
			    console.log('我的开始的数字'+sum);
				console.log('我的开始的name'+name);
				//顶部轮播图
			    if (sum == '4') {
			      sum = sum - Number(this.slideFiles.length);
			    }
			    if (sum == '9') {
			      sum = sum - Number(this.intrFiles.length);
			    }
			    if ((this.photoFiles.length >= 1 && name == 'photo') || (this.ewmFiles.length >= 1 && name == 'ewm') || (this.files.length >= 1 && name == 'pictures') ) {
			      return this.photoShowModal('一');
			    }
			    if (this.slideFiles.length >= 5 && name == 'slideshow') {
			      return this.photoShowModal('五');
			    }
			    if (this.intrFiles.length >= 9 && name == 'introduce') {
			      return this.photoShowModal('九');
			    }
			    uni.chooseImage({
					/*限制最大的数量*/
			      count: sum,
			      sizeType: ['compressed'],
			      sourceType: ['album', 'camera'],
			      success: (res) => {
			        console.log(res);
			        var arr = this.main_getGlobal();
			        let filePaths = res.tempFilePaths;
			        console.log(filePaths)
			        let formData = {'submit': 'submit',}
			        let i = 0;
					console.log('name成功的值',name);
			        if(name == 'photo') {
			          let name = 'shop_avatar';
			          that.uploadFile(formData, filePaths, name, i, arr.token,1,arr.type)
			        }else if(name == 'ewm'){
			          let name = 'wechat_qr_code';
					  console.log('wechat_qr_code的formData所有的值',formData);
					  console.log('wechat_qr_code的filePaths所有的值',filePaths);
					  console.log('wechat_qr_code的name所有的值',name);
					  console.log('wechat_qr_code的i所有的值',i);
					  console.log('wechat_qr_code的arr.token所有的值',arr.token);
					  console.log('wechat_qr_code的arr.type所有的值',arr.type);
			          that.uploadFile(formData, filePaths, name, i, arr.token,2,arr.type)
			        } else if (name == 'pictures') {
			          let name = 'ads_pictures';
			          that.uploadFile(formData, filePaths, name, i, arr.token,5,arr.type)
			        } else if (name == 'slideshow') {
			          let name = 'poster';
					  console.log('所有的值',formData);
					  console.log('所有的值',filePaths);
					  console.log('所有的值',name);
					  console.log('所有的值',i);
					  console.log('所有的值',arr.token);
					  console.log('所有的值',arr.type);
			          that.uploadFile(formData, filePaths, name, i, arr.token,3,arr.type)
			        } else if (name == 'introduce') {
			          let name = 'introduce_map';
			          that.uploadFile(formData, filePaths, name, i, arr.token,4,arr.type)
			        }
			      }
			    })
			  },
			 // 上传图片
			  uploadFile: function (formData, filePaths, name, i, token,type,loginType) {
					gyzjModel.prototype.uploadStorePhoto(formData, filePaths, name, i, token,type,loginType).then(data => {
					  data = JSON.parse(data);
					  uni.showLoading({
						title: '上传中...',
					  })
					  let that=this;
					  switch (data.code) {
						case 1:
						  var arr=this.main_getGlobal();
						  i++;
						  if(i==filePaths.length){
						  	this.myMerchant(arr.token,arr.type);
						  }else{
						  	that.uploadFile(formData, filePaths, name, i, token,type,loginType);
						  }
						  uni.hideLoading();
						  break;
						default:
						  uni.hideLoading();
						  break;
					  }
					});
			  },
		}
	
	}
</script>

<style>
	@import url("../../../static/style/app.css");
	page {
	  width: 100%;
	  height: 100%;
	}
	.page {
	  width: 100%;
	}
	.message {
	  width: 100%;
	  height: 150upx;
	}
	.message image {
	  width: 100%;
	  height: 100%;
	}
	
	.weui-cells {
	  margin-top: 20upx;
	}
	.weui-title {
	  width: 100%;
	  height: 80upx;
	  display: flex;
	  align-items: center;
	  justify-content: center;
	  background-color: #fff;
	  margin-top: 20upx;
	}
	.weui-title-title {
	  margin: 0 20upx;
	  font-weight: 500;
	}
	.weui-title-img {
	  width: 18px; 
	  height: 18px;
	}
	
	.weui-cell__hd {
	  display: flex;
	  width: 33%;
	  align-items: center;
	}
	.weui-cell__hd__img{
	  width: 18px; 
	  height: 18px;
	  margin-right: 10px;
	  display:inline-block;
	}
	.weui-textarea {
	  height: 100upx;
	}
	.dis-hd {
	  display: flex;
	  align-items: center;
	  vertical-align:middle;
	}
	.color-a9 {
	  color: #a9a9a9;
	  font-size: 24upx;
	  margin-left: 10upx;
	}
	
	.btn-area {
	  display: flex;
	  margin-top: 40upx;
	}
	.submit-btn {
	  width: 30%;
	  height: 70upx;
	  background-color: #f94c48;
	  color: #fff;
	  letter-spacing: 5px;
	}
	button {
	  line-height: 70upx;
	}
	
	.service {
	  width: 100%;
	  display: flex;
	  align-items: center;
	  justify-content: center;
	  padding: 40upx 0;
	  font-size: 28upx;
	  font-weight: 600;
	}
	.service-btn {
	  padding: 4upx 20upx;
	  border: 1px solid #f94c48;
	  border-radius: 10upx;
	}
	.radius15 {
	  border-radius: 15upx;
	}
	.padding56 {
	  padding-left: 50upx;
	}
	
	.border-radius {
	  border: 1px solid #f94c48;
	  padding: 2upx 20upx;
	  margin-left: 20upx;
	  background-color: #fff;
	  color: #f94c48;
	  border-radius: 20px;
	}
	
	.changPicture {
	  position: absolute;
	  top: 0em;
	  right: -30upx;
	}
</style>
